#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    setFixedSize(400, 300);

    QPixmap *pixmap = new QPixmap("D:\\Wallparper\\Min_Qt.png");
    ui->image_label->setPixmap(*pixmap);

    connect(ui->auto_login_check_box, &QPushButton::clicked, this, [=]() {
        qDebug() << "自动登录复选框被点击了";

        if (ui->auto_login_check_box->checkState() == Qt::Checked) {
            ui->remember_password_check_box->setCheckState(Qt::Checked);
        }
    });

    connect(ui->remember_password_check_box, &QPushButton::clicked, this, [=]() {
        qDebug() << "记住密码复选框被点击了";

        if (ui->remember_password_check_box->checkState() == Qt::Unchecked) {
            if (ui->auto_login_check_box->checkState() == Qt::Checked) {
                ui->auto_login_check_box->setCheckState(Qt::Unchecked);
            }
        }
    });

    connect(ui->login_button, &QPushButton::clicked, this, [=]() {
        qDebug() << "登录按钮被点击了";

        qDebug() << "Account = " << ui->account_line_edit->text();
        qDebug() << "Password = " << ui->password_line_edit->text();
    });

}

Widget::~Widget()
{
    delete ui;
}

